﻿package com.vinyl.controls
{
	import flash.display.MovieClip;
	import flash.display.GradientType;
	import flash.display.SpreadMethod;
	import flash.geom.*;
	import com.vinyl.controls.ButtonView;

	public class SimpleCheckBoxView extends ButtonView
	{
		private var chk;
		
		public function SimpleCheckBoxView()
		{
			chk = new MovieClip();
			
			chk.x = 3;
			chk.y = 5;
			
			addChild( chk );
		}
		
		override public function setState( state: String ): void
		{
			graphics.clear();
			chk.graphics.clear();
			
			switch( state )
			{
				case ButtonView.ACTIVE_DOWN:
				case ButtonView.NORMAL_UP:
					
					commonFill( 0xCFCFCF );
					break;
					
				case ButtonView.NORMAL_OVER:
					
					commonFill( 0x3ACAC2 );
					break;
					
				case ButtonView.NORMAL_DOWN:
				case ButtonView.ACTIVE_UP:
					
					commonFill( 0xCFCFCF );
					commonCheckFill();
					break;
					
				case ButtonView.ACTIVE_OVER:
					
					commonFill( 0x3ACAC2 );
					commonCheckFill();
					
					break;
			}
		}
		
		private function commonFill( color )
		{
			graphics.beginFill( color );
			graphics.moveTo(0, 0);
			graphics.lineTo(13, 0);
			graphics.lineTo(13, 13);
			graphics.lineTo(0, 13);
			graphics.lineTo(0, 0);
			graphics.endFill();
			
			var fillType:String = GradientType.LINEAR;
			var colors:Array = [0xEEEEEE, 0xFFFFFF];
			var alphas:Array = [1, 1];
			var ratios:Array = [0x00, 0xFF];
			var matr:Matrix = new Matrix();
			matr.createGradientBox(11, 11, 45, 0, 0);
			var spreadMethod:String = SpreadMethod.PAD;
			graphics.beginGradientFill(fillType, colors, alphas, ratios, matr, spreadMethod);        
			graphics.drawRect(1,1,11,11);
		}
		
		private function commonCheckFill()
		{
			chk.graphics.beginFill(0xF86613);
			chk.graphics.moveTo(0, 0);
			chk.graphics.lineTo(0, 1);
			chk.graphics.lineTo(1, 1);
			chk.graphics.lineTo(2, 1);
			chk.graphics.lineTo(2, 2);
			chk.graphics.lineTo(3, 2);
			chk.graphics.lineTo(3, 1);
			chk.graphics.lineTo(4, 1);
			chk.graphics.lineTo(4, 0);	
			chk.graphics.lineTo(5, 0);
			chk.graphics.lineTo(5, -1);
			chk.graphics.lineTo(6, -1);
			chk.graphics.lineTo(6, -2);
			chk.graphics.lineTo(7, -2);
			chk.graphics.lineTo(7, 1);
			chk.graphics.lineTo(6, 1);
			chk.graphics.lineTo(6, 2);	
			chk.graphics.lineTo(5, 2);
			chk.graphics.lineTo(5, 3);
			chk.graphics.lineTo(4, 3);
			chk.graphics.lineTo(4, 4);
			chk.graphics.lineTo(3, 4);
			chk.graphics.lineTo(3, 5);
			chk.graphics.lineTo(2, 5);
			chk.graphics.lineTo(2, 4);	
			chk.graphics.lineTo(1, 4);
			chk.graphics.lineTo(1, 3);
			chk.graphics.lineTo(0, 3);
			chk.graphics.lineTo(0, 0);	
			chk.graphics.endFill();
		}
	}
}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
